package cn.flexui.flexuiserver.utils;

import cn.hutool.core.math.MathUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author wanmingyu
 * @create 2024/9/30 09:44
 */
public class MathUtils extends MathUtil {


    public static long toFen(BigDecimal amount){
        if (amount == null) {
            return 0L;
        }
        return amount.multiply(new BigDecimal("100")).longValue();
    }

    public static BigDecimal toYuan(long fen) {
        return new BigDecimal(fen).divide(new BigDecimal("100"),2, RoundingMode.HALF_UP);
    }
}
